/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*   File:      CellDataFormat.cpp
*   Author:    刘洋兵
*   Function:  表格中单元格显示数据设计类
*   Time:      2025-09-15
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "CellDataFormat.h"

/**
 * @brief  构造函数
 */
CellDataFormat::CellDataFormat()
{

}

/**
 * @brief  界面显示数据库表时特殊字段转换成对应的显示数据
 * @param  tableView 指定显示控件的对象
 * @param  headerName 指定字段列
 * @param  index 指定行号
 * @return  返回界面需要显示的内容
 */
QString CellDataFormat::setDataCell(QTableView *tableView,
                                    const QString& headerName,
                                    const int& index)
{
    VehicleDataType Vtype;
    QString ToString;
    QString ViewName = tableView->objectName();
    if(ViewName == "tableView_vehicle_profile")
    {
        ToString = Vtype.Vehicle_Profile[headerName][index];
    }
    else if (ViewName == "tableView_vehicle_status"||ViewName == "tableView_vehicle_status_error") {
        ToString = Vtype.Vehicle_Status[headerName][index];
    }
    else if (ViewName == "tableView_map_config") {
        ToString = Vtype.Map_Config[headerName][index];
    }
    else if (ViewName == "tableView_district_seats") {
        ToString = Vtype.District_Seats[headerName][index];
    }
    else if (ViewName == "tableView_nodes") {
        ToString = Vtype.Nodes[headerName][index];
    }
    else if (ViewName == "tableView_forward_obstacle_strategy"||ViewName == "tableView_back_obstacle_strategy"
             ||ViewName == "tableView_left_obstacle_strategy"||ViewName == "tableView_right_obstacle_strategy") {
        ToString = Vtype.Obstacle_Strategy[headerName][index];
    }
    else if (ViewName == "tableView_tasks"||ViewName == "tableView_tasks_error") {
        ToString = Vtype.Tasks[headerName][index];
    }
    else if (ViewName == "tableView_vehicle_action_set") {
        ToString = Vtype.Action_Set[headerName][index];
    }

    return ToString;
}

